import { http } from '@/utils/http/axios';
import {RequestEnum} from "@/enums/httpEnum";

/**
 * @description: 根据用户id获取用户菜单
 */
export function adminMenus() {
  return http.request({
    url: '/menus',
    method: 'GET',
  });
}

/**
 * 获取tree菜单列表
 */
export function getMenuTreeList() {
  return http.request({
    url: '/menu/tree/list',
    method: 'GET'
  });
}

/**
 * 获取完整的菜单列表
 */
export function getMenuList() {
  return http.request({
    url: `/menu/list`,
    method: 'GET',
  });
}

/**
 * 添加菜单
 * @param data
 */
export function addMenu(data) {
  return http.request({
    url: '/menu/add',
    method: RequestEnum.POST,
    data
  }, {
    isShowSuccessMessage: true
  })
}

/**
 * 修改菜单
 * @param id
 * @param data
 */
export function updateMenu(id, data) {
  return http.request({
    url: `/menu/update/${id}`,
    method: RequestEnum.PUT,
    data
  }, {
    isShowSuccessMessage: true
  })
}

/**
 * 删除菜单
 * @param id
 */
export function deleteMenu(id) {
  return http.request({
    url: `/menu/delete/${id}`,
    method: RequestEnum.DELETE
  }, {
    isShowSuccessMessage: true
  })
}
